import numpy as np
import matplotlib.pyplot as plt
from scipy.fft import fft2,  fftshift

image = plt.imread('image_back.png')
red_channel = image[:, :, 0]
green_channel = image[:, :, 1]
blue_channel = image[:, :, 2]
f_green = fft2(green_channel)
f_blue = fft2(blue_channel)
f_red = fft2(red_channel)
fshift_red = fftshift(f_red)
fshift_green = fftshift(f_green)
fshift_blue = fftshift(f_blue)
magnitude_spectrum_red = 20 * np.log(np.abs(fshift_red))
magnitude_spectrum_green = 20 * np.log(np.abs(fshift_green))
magnitude_spectrum_blue = 20 * np.log(np.abs(fshift_blue))
plt.imsave('res_red.png', magnitude_spectrum_red, cmap='gray')
plt.imsave('res_green.png', magnitude_spectrum_green, cmap='gray')
plt.imsave('res_blue.png', magnitude_spectrum_blue, cmap='gray')